package com.example.tests;

import java.util.Collections;
import java.util.List;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;

public class ContactCreationTests extends TestBase {
  @Test
  public void testNonEmptyContactCreation() throws Exception {
    app.getNavigationHelper().openMainPage();
	
    //save old state
	List<ContactData> oldList = app.getContactHelper().getContacts();
	 
	//actions    
    app.getContactHelper().addNewContact();
    ContactData contacts = new ContactData();
	contacts.fname="FNAME";
	contacts.lname="LNAME";
	contacts.address1 ="address1";
	contacts.homeNumber = "777-77-11";
	contacts.mobileNumber = "111-222-333";
	contacts.workNumber = "123";
	contacts.mail1 = "test@mail.com";
	contacts.mail2 = "test2@mail.com";
	contacts.dayOfBirth = "5";
	contacts.monthOfBirth = "June";
	contacts.yearOfBirth = "1983";
	contacts.address2 = "address secondary";
	contacts.phone2 = "Russia";
    app.getContactHelper().fillContactForm(contacts);
    app.getContactHelper().submitContactCreation();
    app.getContactHelper().gotoMainPage();
    //save new state
    List<ContactData> newList = app.getContactHelper().getContacts();
	
    //compare states
    oldList.add(contacts);
	Collections.sort(oldList);
	assertEquals(newList, oldList);

  
  }

 // @Test
  public void testEmptyContactCreation() throws Exception {
    app.getNavigationHelper().openMainPage();
    app.getContactHelper().addNewContact();
    app.getContactHelper().fillContactForm(new ContactData("", "", "", "", "", "", "", "", "-", "-", "", "", ""));
    app.getContactHelper().submitContactCreation();
    app.getContactHelper().gotoMainPage();
  }
}
